package com.markus.basic.HashMap注意事项;

/**
 * Author:markusZhang
 * Date:Create in 2020/9/14 13:36
 * todo:
 */
public class A {
    private int hash;
    private Integer id;
    private String name;
    public A(Integer id,String name){
        this.id = id;
        this.name = name;
    }

    @Override
    public int hashCode() {
        int result = hash;
        if (result == 0){
            result = 31 * result + id.hashCode();
            result = 31 * result + name.hashCode();
        }
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this){
            return true;
        }
        if (! (obj instanceof A)){
            return false;
        }else if (!((A) obj).id.equals(id)){
            return false;
        }else if (!((A) obj).name.equals(name)){
            return false;
        }
        return true;
    }
}
